package com.itheima.controller;


import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.service.ICheckGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkgroup")
@Slf4j
/**
 * 检查组相关接口
 */
public class CheckGroupController {

    @Autowired
    private ICheckGroupService checkGroupService;

    @PostMapping("/add")
    public Result add(@RequestParam("checkitemIds") String checkItemIds, @RequestBody CheckGroup checkGroup) {
        return checkGroupService.add(checkItemIds,checkGroup);
    }

    @GetMapping("/deleteById")
    public Result deleteById(@RequestParam("id") String id){
        return checkGroupService.deleteById(id);
    }

    @GetMapping("/findCheckGroupIdsBySetmealId")
    public Result findCheckGroupIdsBySetmealId(@RequestParam("setmealId") String setmealId){
        return checkGroupService.findCheckGroupIdsBySetmealId(setmealId);
    }

    @PostMapping("/findPage")
    public PageResult<CheckGroup> findPage(@RequestBody QueryPageBean query){
        return checkGroupService.findPage(query);
    }

    @PostMapping("/edit")
    public Result edit(@RequestParam("checkitemIds") String checkItemIds, @RequestBody CheckGroup checkGroup) {
        return checkGroupService.edit(checkItemIds,checkGroup);
    }

    @GetMapping("/findAll")
    public Result findAll(){
        return checkGroupService.findAll();
    }
    @GetMapping("/findById")
    public Result findById(@RequestParam("id") String id){
        return checkGroupService.findById(id);
    }

}
